//  疑问  如果要查找的数字就在数组的首位或者末尾，答案上的代码能查到吗，有空问问




#include <stdio.h>
int main()
{
    int a[10];
    int i;
    int j;
    int t;
    printf("give me a 1x10 list:");
    for(i=0;i<10;i++)
    {
        scanf("%d",&a[i]);
    }
    for(i=0;i<9;i++)
    {
        for(j=0;j<9-i;j++)
        {
            if(a[j]>a[j+1])
            {
                t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
            }
        }
    }
   printf("the list is");
   printf("\n");
   for(i=0;i<10;i++)
   {
       printf("%5d",a[i]);
   }
      printf("\n");
   int number;
   scanf("%d",&number);
   int mid;
   int kaishi;
   int jieshu;
   kaishi=0;
   jieshu=9;
   for(i=0;i<10;i++)
   {
       mid=(kaishi+jieshu)/2;
       if(a[mid]==number)
       {
           printf("find,its order is %d",mid+1);
           break;
       }
       if(a[jieshu]==number)
       {
           printf("find,its order is %d",jieshu+1);
           break;
       }
       if(a[kaishi]==number)
       {
           printf("find,its order is%d",kaishi+1);
           break;
       }

       if(number>a[mid]&&number<a[jieshu])
        {
           kaishi=mid+1;

           continue;
        }
       if(number<a[mid]&&number>a[kaishi])
       {
           jieshu=mid-1;

           continue;
       }
       else
       {
           printf("not find");
           break;
       }
    }
   return 0;
}